package by.msokoloff.javaweb2015.services;

import java.util.Date;
import java.util.List;

import javax.persistence.metamodel.SingularAttribute;

import org.springframework.transaction.annotation.Transactional;

import by.msokoloff.javaweb2015.datamodel.Airport;
import by.msokoloff.javaweb2015.datamodel.Flight;

public interface FlightService {

	Flight get(Integer id);

	List<Flight> getByField(SingularAttribute<Flight, ?> attr, Object val);

	List<Flight> getDirectFlights(Airport depAirport, Airport dstAirport, Date date);

	List<Flight> getDirectFlights(Airport depAirport, Airport dstAirport, Date dateFrom, Date dateTo);

	List<List<Flight>> getInDirectFlights(Airport depAirport, Airport dstAirport, Date date);

	List<List<Flight>> getInDirectFlights(Airport depAirport, Airport dstAirport, Date dateFrom, Date dateTo);

	List<Flight> getAll();

	@Transactional
	void createOrUpdate(Flight flight);

	@Transactional
	void delete(Flight flight);

	@Transactional
	void deleteAll();

	long getCount();

	List<Flight> getAll(SingularAttribute<Flight, ?> sortParam, boolean ascending, int first, int count);

	@Transactional
	void deleteWithRelations(Flight flight);

}
